import 'package:flutter/material.dart';
import 'package:flutter_base/config/app_color.dart';
import 'package:flutter_base/config/app_config.dart';
import 'package:flutter_base/generated/assets.dart';
import 'package:flutter_base/widgets/image/auto_image.dart';
import 'package:flutter_base/widgets/image/image_view.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

/// 分享底部弹窗
/// 用于显示分享选项的底部弹出窗口
class ShareBottomSheet extends StatelessWidget {
  const ShareBottomSheet({super.key});

  /// 显示分享底部弹窗
  Future<dynamic> show() async {
    return await Get.bottomSheet(
      this,
      isScrollControlled: true,
      barrierColor: Colors.black.withOpacity(0.5),
      enableDrag: true,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(bottom: 32.w, left: 18.w, right: 18.w),
      decoration: BoxDecoration(
          color: Colors.white, borderRadius: BorderRadius.circular(24.w)),
      padding: EdgeInsets.symmetric(horizontal: 32.w),
      // decoration: BoxDecoration(
      //   color: Colors.white,
      //
      //   borderRadius: BorderRadius.only(
      //     topLeft: Radius.circular(24.w),
      //     topRight: Radius.circular(24.w),
      //   ),
      // ),
      // padding: EdgeInsets.symmetric(horizontal: 24.w),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          // 顶部指示器
          SizedBox(height: 12.w),
          Container(
            width: 48.w,
            height: 5.w,
            decoration: BoxDecoration(
              color: AppColor.colorF5F5F5,
              borderRadius: BorderRadius.circular(50.w),
            ),
          ),
          SizedBox(height: 16.w),

          // 标题
          Text(
            'share',
            style: TextStyle(
              fontFamily: 'Urbanist',
              fontSize: 16.sp,
              fontWeight: FontWeight.bold,
              color: AppColor.color0C0A09,
            ),
            textAlign: TextAlign.center,
          ),

          SizedBox(height: 32.w),

          // 分享图标行
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              _buildShareItem(
                iconAsset: Assets.commonShareWa,
                label: "WhatsApp",
                onTap: () => _handleShare("whatsapp"),
              ),
              _buildShareItem(
                iconAsset: Assets.commonShareTw,
                label: "Twitter",
                onTap: () => _handleShare("twitter"),
              ),
              _buildShareItem(
                iconAsset: Assets.commonShareFb,
                label: "Facebook",
                onTap: () => _handleShare("facebook"),
              ),
              _buildShareItem(
                iconAsset: Assets.commonShareIns,
                label: "Instagram",
                onTap: () => _handleShare("instagram"),
              ),
            ],
          ),

          SizedBox(height: 24.w),
        ],
      ),
    );
  }

  /// 构建单个分享项
  Widget _buildShareItem({
    required String iconAsset,
    required String label,
    required VoidCallback onTap,
  }) {
    return GestureDetector(
      onTap: onTap,
      child: Column(
        children: [
          AutoImage(
            iconAsset,
            width: 48.w,
          ),

          SizedBox(height: 8.w),
          // 标签
          Text(
            label,
            style: TextStyle(
              fontFamily: 'Outfit',
              fontSize: 12.sp,
              fontWeight: FontWeight.w500,
              color: AppColor.color333333,
              letterSpacing: 0.2,
            ),
            textAlign: TextAlign.center,
          ),
        ],
      ),
    );
  }

  /// 处理分享操作
  void _handleShare(String platform) {
    // 处理分享逻辑

    Get.back();
    // 实际分享代码...
  }
}
